﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgClave.aspx.cs" Inherits="EGuayas.Web.Usuario.pgClave" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title><link  href="~/Resources/css/Style.css"  rel="stylesheet" /><!-- Load Ext JS --> 
    <script src="../Resources/js/Global.js"></script>
</head>
<body>
     <ext:ResourceManager ID="ResourceManager1" runat="server" />
     
             <ext:FormPanel 
                    ID="FormPanel1" 
                    runat="server" 
                    Title="Cambiar clave"
                    BodyPadding="5"                                        
                    ButtonAlign="Center"
                    Border="false"
                    Layout="Form">
                    <Items>
                          <ext:TextField 
                            ID="txtPassword0" 
                            runat="server"                             
                            InputType="Password" 
                            FieldLabel="Clave anterior" 
                            AllowBlank="false" 
                            BlankText="Clave es requerida">
                           </ext:TextField>
                      
                          <ext:TextField 
                            ID="txtPassword1" 
                            runat="server"                          
                            InputType="Password" 
                            FieldLabel="Nueva clave" 
                            AllowBlank="false" 
                            BlankText="Clave es requerida">                             
                            <Validator Handler="return pgFn.validatePassword(#{txtPassword1}, #{txtPassword2});" />
                           </ext:TextField>
                          <ext:TextField 
                                ID="txtPassword2" 
                                runat="server"             
                                InputType="Password" 
                                FieldLabel="Repita clave" 
                                AllowBlank="false" 
                                BlankText="Clave es requerida">
                                <Validator Handler="return pgFn.validatePassword(#{txtPassword1}, #{txtPassword2});" />
                          </ext:TextField>
                     </Items>
                        <BottomBar>
                            <ext:StatusBar ID="StatusBar1" runat="server" />
                        </BottomBar>
                        <Listeners>
                            <ValidityChange Handler="this.dockedItems.get(1).setStatus({
                                                            text : valid ? 'Datos validos' : 'Datos no validos', 
                                                            iconCls: valid ? 'icon-accept' : 'icon-exclamation'
                                                        });
                                                        #{Button1}.setDisabled(!valid);" />
                        </Listeners>
                 <Buttons>
            <ext:Button ID="Button1" runat="server" Text="Aceptar"  Disabled="true">
                <DirectEvents>
                    <Click OnEvent="CambiarClaveClick" Success="#{Window1}.close();" Before="return pgFn.validFormGeneral(this);">
                        <ExtraParams>
                          <ext:Parameter Name="prmValues" Value="Ext.encode(this.up('form').getForm().getValues())" Mode="Raw" />
                        </ExtraParams>
                        <EventMask ShowMask="true" Msg="Verifying..." MinDelay="1000" />
                    </Click>
                </DirectEvents>
            </ext:Button>
        </Buttons>

                </ext:FormPanel>
        
     <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
            var pgFn = new Object();
            pgFn.generatePassword = function (me) {
                try
                {
                    var txfmask = me.up('textfield').passwordMask;
                    txfmask.generatePassword(); 
                    #{PassMode}.toggle(true, true);

                } catch (jsbug) {
                    AppGlobalJs.showBug("pgFn.generatePassword : " + jsbug)
                }
            }; 
            pgFn.validFormGeneral = function () {
                try
                {
                    var done=#{FormPanel1}.getForm().isValid();
                    return(done);

                } catch (jsbug) {
                    AppGlobalJs.showBug(" pgFn.validFormGeneral : " + jsbug)
                }
            };           
            pgFn.validatePassword = function (control1, control2) {
                try
                {
                  
                    if (control1.getValue() != control2.getValue() && control1.getValue() != '' && control2.getValue() != '') {
                        control1.markInvalid("Clave no similar.");
                        control2.markInvalid("Clave no similar.");
                        return false;
                    }
                    return true;
                } catch (jsbug) {
                    AppGlobalJs.showBug("pgFn.validatePassword: " + jsbug)
                }

            };
       </script>
    </ext:XScript>
</body>
</html>
